--[[
	Ikarus Unit-Frames Addon	
	released under GNU General Public License version 3 (GPLv3) 
	by McGaerty & Sl4ker
	
	contact: mcgaerty@ikarus-systems.net rom@sl4ker.de	
	download: http://rom.curse.com/downloads/rom-addons/details/ikarus-unitframes.aspx
	
	special thanks to Qwox and novayuna for inspiration and stable basics
]]



do

ikarus.config.defaults.party = {
	["GENERAL"] = {
		["PROXY"] = true,
		["VISIBLE"] = true,
		["HIDE_IN_RAID"] = false,
		["FRAME"] = "Ikarus_PartyFrame",
		["WOW_STYLE"] = false,
		["USE_DEFAULT_FRAME"] = true,
		["OFFSET_X"] = 55,
		["OFFSET_Y"] = 250,
		["WIDTH"] = 100,
		["HEIGHT"] = 45,
		["ORIENTATION"] = "VERTICAL",
		["SPACING"] = 30,
		["ALPHA"] = 1.0,
		["NUMBER_FORMAT"] = "UNFORMATTED",
		["FRAME_LOCKED"] = false,
		["SCALE"] = 1.0
	},
	
	["DOCKING"] = {
		["ENABLE"] = true,
		["TARGET"] = "PLAYER",
		["OFFSET_X"] = 0,
		["OFFSET_Y"] = 60,
		["ALIGNMENT"] = "BOTTOMLEFT"
	},
	
	["HEALTHBAR"] = {
		["VISIBLE"] = true,
		["CLASS_COLOR"] = false,
		["WEIGHT"] = 60,
		["TEXTURE"] = "Healbot",
		["COLORIZER"] = "NONE",
		["FOREGROUND_COLOR"] = { r = 1.0, g = 0.04, b = 0.02 },
		["BACKGROUND_COLOR"] = { r = 0.2, g = 0.4, b = 0.65 },
		
		["LEFTTEXT_VISIBLE"] = true,
		["LEFTTEXT_OFFSET_X"] = 5,
		["LEFTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["LEFTTEXT_FONT"] = "Default",
		["LEFTTEXT_FONTSIZE"] = 10,
		["LEFTTEXT_COLORIZER"] = "NONE",
		["LEFTTEXT_CONTENT"] = "[NAME]",
		
		["RIGHTTEXT_VISIBLE"] = true,
		["RIGHTTEXT_OFFSET_X"] = 1,
		["RIGHTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["RIGHTTEXT_FONT"] = "Default",
		["RIGHTTEXT_FONTSIZE"] = 10,
		["RIGHTTEXT_COLORIZER"] = "NONE",
		["RIGHTTEXT_CONTENT"] = "[HP]",
		
		["OUTSIDE_LEFTTEXT_VISIBLE"] = false,
		["OUTSIDE_LEFTTEXT_OFFSET_X"] = 1,
		["OUTSIDE_LEFTTEXT_TEXTCOLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["OUTSIDE_LEFTTEXT_FONT"] = "Default",
		["OUTSIDE_LEFTTEXT_FONTSIZE"] = 10,
		["OUTSIDE_LEFTTEXT_COLORIZER"] = "NONE",
		["OUTSIDE_LEFTTEXT_CONTENT"] = "",
		
		["OUTSIDE_RIGHTTEXT_VISIBLE"] = false,
		["OUTSIDE_RIGHTTEXT_OFFSET_X"] = 1,
		["OUTSIDE_RIGHTTEXT_TEXTCOLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["OUTSIDE_RIGHTTEXT_FONT"] = "Default",
		["OUTSIDE_RIGHTTEXT_FONTSIZE"] = 10,
		["OUTSIDE_RIGHTTEXT_COLORIZER"] = "NONE",
		["OUTSIDE_RIGHTTEXT_CONTENT"] = ""
	},
	
	["MANABAR"] = {
		["VISIBLE"] = true,
		["SYSTEM_COLOR"] = false,
		["OFFSET_X"] = 1,
		["OFFSET_Y"] = 1,
		["WEIGHT"] = 25,
		["TEXTURE"] = "Healbot",
		["COLORIZER"] = "NONE",
		["FOREGROUND_COLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["BACKGROUND_COLOR"] = { r = 0.2, g = 0.4, b = 0.65 },
		
		["LEFTTEXT_VISIBLE"] = false,
		["LEFTTEXT_OFFSET_X"] = 50,
		["LEFTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["LEFTTEXT_FONT"] = "Default",
		["LEFTTEXT_FONTSIZE"] = 10,
		["LEFTTEXT_COLORIZER"] = "NONE",
		["LEFTTEXT_CONTENT"] = "[MP]",
		
		["RIGHTTEXT_VISIBLE"] = false,
		["RIGHTTEXT_OFFSET_X"] = 1,
		["RIGHTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["RIGHTTEXT_FONT"] = "Default",
		["RIGHTTEXT_FONTSIZE"] = 10,
		["RIGHTTEXT_COLORIZER"] = "NONE",
		["RIGHTTEXT_CONTENT"] = "[MANA_TYPE]",
		
		["OUTSIDE_LEFTTEXT_VISIBLE"] = false,
		["OUTSIDE_LEFTTEXT_OFFSET_X"] = 1,
		["OUTSIDE_LEFTTEXT_TEXTCOLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["OUTSIDE_LEFTTEXT_FONT"] = "Default",
		["OUTSIDE_LEFTTEXT_FONTSIZE"] = 10,
		["OUTSIDE_LEFTTEXT_COLORIZER"] = "NONE",
		["OUTSIDE_LEFTTEXT_CONTENT"] = "",
		
		["OUTSIDE_RIGHTTEXT_VISIBLE"] = false,
		["OUTSIDE_RIGHTTEXT_OFFSET_X"] = 1,
		["OUTSIDE_RIGHTTEXT_TEXTCOLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["OUTSIDE_RIGHTTEXT_FONT"] = "Default",
		["OUTSIDE_RIGHTTEXT_FONTSIZE"] = 10,
		["OUTSIDE_RIGHTTEXT_COLORIZER"] = "NONE",
		["OUTSIDE_RIGHTTEXT_CONTENT"] = ""
	},
	
	["SKILLBAR"] = {
		["VISIBLE"] = true,
		["SYSTEM_COLOR"] = false,
		["OFFSET_X"] = 1,
		["OFFSET_Y"] = 1,
		["WEIGHT"] = 25,
		["TEXTURE"] = "Healbot",
		["COLORIZER"] = "NONE",
		["FOREGROUND_COLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["BACKGROUND_COLOR"] = { r = 0.2, g = 0.4, b = 0.65 },
		
		["LEFTTEXT_VISIBLE"] = false,
		["LEFTTEXT_OFFSET_X"] = 50,
		["LEFTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["LEFTTEXT_FONT"] = "Default",
		["LEFTTEXT_FONTSIZE"] = 10,
		["LEFTTEXT_COLORIZER"] = "NONE",
		["LEFTTEXT_CONTENT"] = "[SP]",
		
		["RIGHTTEXT_VISIBLE"] = false,
		["RIGHTTEXT_OFFSET_X"] = 1,
		["RIGHTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["RIGHTTEXT_FONT"] = "Default",
		["RIGHTTEXT_FONTSIZE"] = 10,
		["RIGHTTEXT_COLORIZER"] = "NONE",
		["RIGHTTEXT_CONTENT"] = "[SKILL_TYPE]",
		
		["OUTSIDE_LEFTTEXT_VISIBLE"] = false,
		["OUTSIDE_LEFTTEXT_OFFSET_X"] = 1,
		["OUTSIDE_LEFTTEXT_TEXTCOLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["OUTSIDE_LEFTTEXT_FONT"] = "Default",
		["OUTSIDE_LEFTTEXT_FONTSIZE"] = 10,
		["OUTSIDE_LEFTTEXT_COLORIZER"] = "NONE",
		["OUTSIDE_LEFTTEXT_CONTENT"] = "",
		
		["OUTSIDE_RIGHTTEXT_VISIBLE"] = false,
		["OUTSIDE_RIGHTTEXT_OFFSET_X"] = 1,
		["OUTSIDE_RIGHTTEXT_TEXTCOLOR"] = { r = 0.3, g = 0.5, b = 0.85 },
		["OUTSIDE_RIGHTTEXT_FONT"] = "Default",
		["OUTSIDE_RIGHTTEXT_FONTSIZE"] = 10,
		["OUTSIDE_RIGHTTEXT_COLORIZER"] = "NONE",
		["OUTSIDE_RIGHTTEXT_CONTENT"] = ""
	},
	
	["BUFFS"] = {
		["BUFFS_VISIBLE"] = true,
		["BUFFS_SHOW_DURATION"] = false,
		["BUFFS_OFFSET_X"] = 0,
		["BUFFS_OFFSET_Y"] = 2,
		["BUFFS_SCALE"] = 0.7,
		["BUFFS_FONTSIZE"] = 14,
		["BUFFS_COLUMNS"] = 10,
		["BUFFS_SPACING"] = 2,
		["BUFFS_ALIGNMENT"] = "BOTTOMLEFT",
		
		["DEBUFFS_VISIBLE"] = true,
		["DEBUFFS_SHOW_DURATION"] = false,
		["DEBUFFS_OFFSET_X"] = 2,
		["DEBUFFS_OFFSET_Y"] = 0,
		["DEBUFFS_SCALE"] = 0.7,
		["DEBUFFS_FONTSIZE"] = 14,
		["DEBUFFS_COLUMNS"] = 10,
		["DEBUFFS_SPACING"] = 2,
		["DEBUFFS_ALIGNMENT"] = "RIGHT"
	},
	
	["PORTRAIT"] = {
		["VISIBLE"] = false,
		["OFFSET_X"] = 1,
		["OFFSET_Y"] = 1,
		["WIDTH"] = 52,
		["HEIGHT"] = 52,
		["SCALE"] = 1.0,
		["ALIGNMENT"] = "LEFT",
	},
	
	["ICONS"] = {	
		["DISCONNECT_VISIBLE"] = true,
		["DISCONNECT_OFFSET_X"] = 5,
		["DISCONNECT_OFFSET_Y"] = 0,
		["DISCONNECT_WIDTH"] = 40,
		["DISCONNECT_HEIGHT"] = 40,
		["DISCONNECT_SCALE"] = 0.7,
		["DISCONNECT_ALIGNMENT"] = "LEFT",
		
		["RAIDTARGET_VISIBLE"] = true,
		["RAIDTARGET_OFFSET_X"] = 2,
		["RAIDTARGET_OFFSET_Y"] = 12,
		["RAIDTARGET_WIDTH"] = 32,
		["RAIDTARGET_HEIGHT"] = 32,
		["RAIDTARGET_SCALE"] = 1.0,
		["RAIDTARGET_ALIGNMENT"] = "RIGHT",
		
		["PVPSTATE_VISIBLE"] = true,
		["PVPSTATE_OFFSET_X"] = 1,
		["PVPSTATE_OFFSET_Y"] = 1,
		["PVPSTATE_WIDTH"] = 16,
		["PVPSTATE_HEIGHT"] = 16,
		["PVPSTATE_SCALE"] = 1.0,
		["PVPSTATE_ALIGNMENT"] = "RIGHT",
		
		["LOOTMASTER_VISIBLE"] = true,
		["LOOTMASTER_OFFSET_X"] = 15,
		["LOOTMASTER_OFFSET_Y"] = 1,
		["LOOTMASTER_WIDTH"] = 13,
		["LOOTMASTER_HEIGHT"] = 13,
		["LOOTMASTER_SCALE"] = 1.0,
		["LOOTMASTER_ALIGNMENT"] = "TOPLEFT",
		
		["RAIDLEADER_VISIBLE"] = true,
		["RAIDLEADER_OFFSET_X"] = 1,
		["RAIDLEADER_OFFSET_Y"] = 1,
		["RAIDLEADER_WIDTH"] = 13,
		["RAIDLEADER_HEIGHT"] = 13,
		["RAIDLEADER_SCALE"] = 1.0,
		["RAIDLEADER_ALIGNMENT"] = "TOPLEFT",
		
		["BOSS_VISIBLE"] = false,
		
		["MAINCLASS_VISIBLE"] = false,
		["MAINCLASS_OFFSET_X"] = 1,
		["MAINCLASS_OFFSET_Y"] = 1,
		["MAINCLASS_WIDTH"] = 20,
		["MAINCLASS_HEIGHT"] = 20,
		["MAINCLASS_SCALE"] = 1.0,
		["MAINCLASS_ALIGNMENT"] = "TOPLEFT",
		
		["SUBCLASS_VISIBLE"] = false,
		["SUBCLASS_OFFSET_X"] = 1,
		["SUBCLASS_OFFSET_Y"] = 1,
		["SUBCLASS_WIDTH"] = 16,
		["SUBCLASS_HEIGHT"] = 16,
		["SUBCLASS_SCALE"] = 1.0,
		["SUBCLASS_ALIGNMENT"] = "TOPLEFT"
	},
	
	["LABELS"] = {
		["TOPTEXT_VISIBLE"] = false,
		["TOPTEXT_OFFSET_X"] = 20,
		["TOPTEXT_OFFSET_Y"] = 1,
		["TOPTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["TOPTEXT_FONT"] = "Default",
		["TOPTEXT_FONTSIZE"] = 10,
		["TOPTEXT_COLORIZER"] = "NONE",
		["TOPTEXT_CONTENT"] = "[NAME]    [CLASS]/[SCLASS]",
		
		["RIGHTTEXT_VISIBLE"] = false,
		["RIGHTTEXT_OFFSET_X"] = 1,
		["RIGHTTEXT_OFFSET_Y"] = 1,
		["RIGHTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["RIGHTTEXT_FONT"] = "Default",
		["RIGHTTEXT_FONTSIZE"] = 10,
		["RIGHTTEXT_COLORIZER"] = "NONE",
		["RIGHTTEXT_CONTENT"] = "",
		
		["BOTTOMTEXT_VISIBLE"] = false,
		["BOTTOMTEXT_OFFSET_X"] = 1,
		["BOTTOMTEXT_OFFSET_Y"] = 1,
		["BOTTOMTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["BOTTOMTEXT_FONT"] = "Default",
		["BOTTOMTEXT_FONTSIZE"] = 10,
		["BOTTOMTEXT_COLORIZER"] = "NONE",
		["BOTTOMTEXT_CONTENT"] = "[LVL]/[SLVL]",
		
		["LEFTTEXT_VISIBLE"] = false,
		["LEFTTEXT_OFFSET_X"] = 1,
		["LEFTTEXT_OFFSET_Y"] = 1,
		["LEFTTEXT_TEXTCOLOR"] = { r = 1.0, g = 1.0, b = 1.0 },
		["LEFTTEXT_FONT"] = "Default",
		["LEFTTEXT_FONTSIZE"] = 10,
		["LEFTTEXT_COLORIZER"] = "NONE",
		["LEFTTEXT_CONTENT"] = ""
	}
};

table.insert(ikarus.config.interface, 
	{
		"party",
		
		--  General
		
		{
			"GENERAL", 
	        {"VISIBLE", nil,nil,"CHECKBOX", true},
	        {"USE_DEFAULT_FRAME", nil, nil,"CHECKBOX", true},
			{"WOW_STYLE", nil, nil,"CHECKBOX"},
			{"DUMMY_STATE", nil, nil,"BUTTON", false}, 
			{"HIDE_IN_RAID", nil, nil,"CHECKBOX",true},
	        {"OFFSET_X", nil, nil,"SLIDER",false,0,"##interface.MAX_OFFSET_X"},
	        {"OFFSET_Y", nil, nil,"SLIDER",false,0,"##interface.MAX_OFFSET_Y"},
			{"WIDTH", nil, nil,"SLIDER",false,50,400},
			{"HEIGHT", nil, nil,"SLIDER",false,20,200},
			{"SPACING", nil, nil,"SLIDER",false,0,100},
	        {"ORIENTATION", nil, nil,"COMBOBOX", false, {"HORIZONTAL","VERTICAL"}, true},
	        {"ALPHA", nil, nil,"SLIDER", false, 0.0,1.0, 0.1},
	        {"NUMBER_FORMAT", nil, nil,"COMBOBOX", false, "##interface.NUMBER_FORMATS", true},
	        {"FRAME_LOCKED", nil, nil,"CHECKBOX"},
	        {"SCALE", nil, nil,"SLIDER",false,0.5,2.0}
		},
		
		--  Docking
		
		{
			"DOCKING", 
	        {"ENABLE", nil,nil,"CHECKBOX", false},
	        {"TARGET", nil, nil,"COMBOBOX", false, {"PLAYER","PLAYERCASTBAR","TARGET"}, true},
	        {"OFFSET_X", nil, nil,"SLIDER",false,-500,500},
	        {"OFFSET_Y", nil, nil,"SLIDER",false,-500,500},
	        {"ALIGNMENT", nil,nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
		},
		
		--  Healthbar
		
		{	
			"HEALTHBAR",
			"GENERAL",
			{"VISIBLE", nil,nil,"CHECKBOX", true},
	        {"CLASS_COLOR", nil,nil,"CHECKBOX"},
			{"WEIGHT", nil,nil,"SLIDER",false,20,100,"LOW", "HIGH"},
			{"TEXTURE", nil,nil,"COMBOBOX",true,"##interface.BAR_TEXTURES"},
			{"COLORIZER", nil,nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"FOREGROUND_COLOR", nil,nil,"COLORPICKER"},
			{"BACKGROUND_COLOR", nil,nil,"COLORPICKER"},
			
			"LEFTTEXT",
			{"LEFTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", true},
			{"LEFTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"LEFTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"LEFTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"LEFTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"LEFTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"LEFTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"},
			
			"RIGHTTEXT",
			{"RIGHTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"RIGHTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"RIGHTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"RIGHTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"RIGHTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"RIGHTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"RIGHTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth", 0},
			
			"OUTSIDE_LEFTTEXT",
			{"OUTSIDE_LEFTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"OUTSIDE_LEFTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"OUTSIDE_LEFTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"OUTSIDE_LEFTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"OUTSIDE_LEFTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"OUTSIDE_LEFTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"OUTSIDE_LEFTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth", 0},
			
			"OUTSIDE_RIGHTTEXT",
			{"OUTSIDE_RIGHTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"OUTSIDE_RIGHTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"OUTSIDE_RIGHTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"OUTSIDE_RIGHTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"OUTSIDE_RIGHTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"OUTSIDE_RIGHTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"OUTSIDE_RIGHTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"}
		},
		
		--  Manabar
		
		{	
			"MANABAR",
			"GENERAL",
			{"VISIBLE", nil,nil,"CHECKBOX", true},
	        {"SYSTEM_COLOR", nil,nil,"CHECKBOX"},
			{"WEIGHT", nil,nil,"SLIDER",false,20,100, 1,"LOW", "HIGH"},
			{"TEXTURE", nil,nil,"COMBOBOX",true,"##interface.BAR_TEXTURES"},
			{"COLORIZER", nil,nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"FOREGROUND_COLOR", nil,nil,"COLORPICKER"},
			{"BACKGROUND_COLOR", nil,nil,"COLORPICKER"},
			
			"LEFTTEXT",
			{"LEFTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", true},
			{"LEFTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"LEFTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"LEFTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"LEFTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"LEFTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"LEFTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"},
			
			"RIGHTTEXT",
			{"RIGHTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"RIGHTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"RIGHTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"RIGHTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"RIGHTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"RIGHTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"RIGHTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth", 0},
			
			"OUTSIDE_LEFTTEXT",
			{"OUTSIDE_LEFTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"OUTSIDE_LEFTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"OUTSIDE_LEFTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"OUTSIDE_LEFTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"OUTSIDE_LEFTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"OUTSIDE_LEFTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"OUTSIDE_LEFTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth", 0},
			
			"OUTSIDE_RIGHTTEXT",
			{"OUTSIDE_RIGHTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"OUTSIDE_RIGHTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"OUTSIDE_RIGHTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"OUTSIDE_RIGHTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"OUTSIDE_RIGHTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"OUTSIDE_RIGHTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"OUTSIDE_RIGHTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"}
		},
		
		--  Skillbar
		
		{	
			"SKILLBAR",
			"GENERAL",
			{"VISIBLE", nil,nil,"CHECKBOX", true},
	        {"SYSTEM_COLOR", nil,nil,"CHECKBOX"},
			{"WEIGHT", nil,nil,"SLIDER",false,20,100,"LOW", "HIGH"},
			{"TEXTURE", nil,nil,"COMBOBOX",true,"##interface.BAR_TEXTURES"},
			{"COLORIZER", nil,nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"FOREGROUND_COLOR", nil,nil,"COLORPICKER"},
			{"BACKGROUND_COLOR", nil,nil,"COLORPICKER"},
			
			"LEFTTEXT",
			{"LEFTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", true},
			{"LEFTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"LEFTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"LEFTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"LEFTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"LEFTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"LEFTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"},
			
			"RIGHTTEXT",
			{"RIGHTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"RIGHTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"RIGHTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"RIGHTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"RIGHTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"RIGHTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"RIGHTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth", 0},
			
			"OUTSIDE_LEFTTEXT",
			{"OUTSIDE_LEFTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"OUTSIDE_LEFTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"OUTSIDE_LEFTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"OUTSIDE_LEFTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"OUTSIDE_LEFTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"OUTSIDE_LEFTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"OUTSIDE_LEFTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth", 0},
			
			"OUTSIDE_RIGHTTEXT",
			{"OUTSIDE_RIGHTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", false},
			{"OUTSIDE_RIGHTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"OUTSIDE_RIGHTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"OUTSIDE_RIGHTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"OUTSIDE_RIGHTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"OUTSIDE_RIGHTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"OUTSIDE_RIGHTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"}
		},
		
		--  Buffs
		
		{
			"BUFFS",
			"BUFFS",
			{"BUFFS_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"BUFFS_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"BUFFS_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,-50,50},
			{"BUFFS_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"BUFFS_SHOW_DURATION", "SHOW_DURATION",nil,"CHECKBOX"},
			{"BUFFS_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"BUFFS_COLUMNS", "COLUMNS",nil,"SLIDER",false,4,20},
			{"BUFFS_SPACING", "SPACING",nil,"SLIDER",false,0,10},
			{"BUFFS_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
			"DEBUFFS",
			{"DEBUFFS_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"DEBUFFS_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"DEBUFFS_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,-50,50},
			{"DEBUFFS_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"DEBUFFS_SHOW_DURATION", "SHOW_DURATION",nil,"CHECKBOX"},
			{"DEBUFFS_COLUMNS", "COLUMNS",nil,"SLIDER",false,4,20},
			{"DEBUFFS_SPACING", "SPACING",nil,"SLIDER",false,0,10},
			{"DEBUFFS_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"DEBUFFS_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true}	
		},
		
		--	Portrait
		
		{
			"PORTRAIT",
			{"VISIBLE", nil,nil,"CHECKBOX"},
			{"OFFSET_X", nil,nil,"SLIDER",false,-100,"$$Ikarus_PartyFrame.GetWidth"},
			{"OFFSET_Y", nil,nil,"SLIDER",false,-50,50},
			{"SCALE", nil,nil,"SLIDER",false,0.5,2.0},
			{"ALIGNMENT", nil,nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
		},
		
		--	Icons
		
		{
			"ICONS",
			"DISCONNECT",
			{"DISCONNECT_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"DISCONNECT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"DISCONNECT_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetHeight","$$Ikarus_PartyFrame.GetHeight"},
			{"DISCONNECT_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"DISCONNECT_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
			"RAIDTARGET",
			{"RAIDTARGET_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"RAIDTARGET_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"RAIDTARGET_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetHeight","$$Ikarus_PartyFrame.GetHeight"},
			{"RAIDTARGET_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"RAIDTARGET_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
			"PVPSTATE",
			{"PVPSTATE_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"PVPSTATE_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"PVPSTATE_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetHeight","$$Ikarus_PartyFrame.GetHeight"},
			{"PVPSTATE_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"PVPSTATE_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
			"LOOTMASTER",
			{"LOOTMASTER_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"LOOTMASTER_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"LOOTMASTER_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetHeight","$$Ikarus_PartyFrame.GetHeight"},
			{"LOOTMASTER_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"LOOTMASTER_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
			"RAIDLEADER",
			{"RAIDLEADER_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"RAIDLEADER_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"RAIDLEADER_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetHeight","$$Ikarus_PartyFrame.GetHeight"},
			{"RAIDLEADER_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"RAIDLEADER_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
			"MAINCLASS",
			{"MAINCLASS_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"MAINCLASS_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"MAINCLASS_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetHeight","$$Ikarus_PartyFrame.GetHeight"},
			{"MAINCLASS_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"MAINCLASS_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true},
			"SUBCLASS",
			{"SUBCLASS_VISIBLE", "VISIBLE",nil,"CHECKBOX"},
			{"SUBCLASS_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetWidth","$$Ikarus_PartyFrame.GetWidth"},
			{"SUBCLASS_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,"$$Ikarus_PartyFrame.GetHeight","$$Ikarus_PartyFrame.GetHeight"},
			{"SUBCLASS_SCALE", "SCALE",nil,"SLIDER",false,0.5,2.0},
			{"SUBCLASS_ALIGNMENT", "ALIGNMENT",nil,"COMBOBOX",false,"##interface.ALIGNMENTS", true}
		},
		
		--	Labels
		
		{
			"LABELS",
			"TOPTEXT",
			{"TOPTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", true},
			{"TOPTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"TOPTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"TOPTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"TOPTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"TOPTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"TOPTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"},
			{"TOPTEXT_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,-100,0},
			"RIGHTTEXT",
			{"RIGHTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", true},
			{"RIGHTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"RIGHTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"RIGHTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"RIGHTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"RIGHTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"RIGHTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,100},
			{"RIGHTTEXT_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,0,50},
			"BOTTOMTEXT",
			{"BOTTOMTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", true},
			{"BOTTOMTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"BOTTOMTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"BOTTOMTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"BOTTOMTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"BOTTOMTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"BOTTOMTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,0,"$$Ikarus_PartyFrame.GetWidth"},
			{"BOTTOMTEXT_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,0,100},
			"LEFTTEXT",
			{"LEFTTEXT_VISIBLE", "VISIBLE",nil,"CHECKBOX", true},
			{"LEFTTEXT_TEXTCOLOR", "TEXT_COLOR",nil,"COLORPICKER"},
			{"LEFTTEXT_FONT", "FONT",nil,"COMBOBOX",true,"##interface.FONTS"},
			{"LEFTTEXT_FONTSIZE", "FONT_SIZE",nil,"SLIDER",false,"##interface.MIN_FONT_SIZE","##interface.MAX_FONT_SIZE"},
			{"LEFTTEXT_CONTENT", "CONTENT",nil,"TEXTFIELD"},
			{"LEFTTEXT_COLORIZER", "COLORIZER",nil,"COMBOBOX",true,"##interface.COLORIZERS", true},
			{"LEFTTEXT_OFFSET_X", "OFFSET_X",nil,"SLIDER",false,-100,0},
			{"LEFTTEXT_OFFSET_Y", "OFFSET_Y",nil,"SLIDER",false,0,50}
		}
    }
);


--  ***********************************************************************
--  class handling player unit frame behavior
ikarus.delegates.PartyUnitDelegateClass = ikarus:NewClass(ikarus.delegates.BasicUnitDelegateClass);

ikarus.delegates.PartyUnitDelegateClass.Proxy = ikarus:NewClass(ikarus.delegates.BasicUnitDelegateClass);

function ikarus.delegates.PartyUnitDelegateClass:Init()
	self.unit = "party";
	self.frame = getglobal(ikarus.config.defaults.party.GENERAL.FRAME);
	self.frameName = self.frame:GetName();
	self.eventList = {
		["UNIT_LEVEL"] 				= ikarus.delegates.PartyUnitDelegateClass.UpdateAll;
		["UNIT_HEALTH"] 			= ikarus.delegates.BasicUnitDelegateClass.UpdateHealth; 
		["UNIT_MAXHEALTH"] 			= ikarus.delegates.BasicUnitDelegateClass.UpdateHealth; 
		["UNIT_MANA"] 				= ikarus.delegates.BasicUnitDelegateClass.UpdateMana; 
		["UNIT_MAXMANA"] 			= ikarus.delegates.BasicUnitDelegateClass.UpdateMana; 
		["UNIT_SKILL"] 				= ikarus.delegates.BasicUnitDelegateClass.UpdateSkill; 
		["UNIT_MAXSKILL"] 			= ikarus.delegates.BasicUnitDelegateClass.UpdateSkill; 
		["UNIT_BUFF_CHANGED"] 		= ikarus.delegates.BasicUnitDelegateClass.UpdateBuffs; 
		["UNIT_PORTRAIT_UPDATE"] 	= ikarus.delegates.BasicUnitDelegateClass.UpdatePortrait; 
		["RAID_TARGET_CHANGED"] 	= ikarus.delegates.BasicUnitDelegateClass.UpdateRaidTargetIcon; 
		["UNIT_TARGET_CHANGED"] 	= ikarus.delegates.BasicUnitDelegateClass.UpdateText;
		["PARTY_MEMBER_CHANGED"] 	= ikarus.delegates.PartyUnitDelegateClass.UpdateAll; 
		["PARTY_LEADER_CHANGED"] 	= ikarus.delegates.BasicUnitDelegateClass.UpdatePartyLeaderIcon; 
		["UPDATE_PARALLEL"] 		= ikarus.delegates.BasicUnitDelegateClass.UpdateChannel; 
		["UPDATE_LOOT_ASSIGN"] 		= ikarus.delegates.BasicUnitDelegateClass.UpdateLootMasterIcon; 
		["LOOT_METHOD_CHANGED"] 	= ikarus.delegates.BasicUnitDelegateClass.UpdateLootMasterIcon 
	};
end;

function ikarus.delegates.PartyUnitDelegateClass:Profile()
	return ikarus.profile.party;
end;

function ikarus.delegates.PartyUnitDelegateClass:ResetProfile()
	local config = ikarus.profile.party;
	config.GENERAL.FRAME = self.frameName;
	config.GENERAL.VISIBLE = self.visible;
	config.DOCKING.ENABLE = self.docking;
	self.frame = getglobal(self.frameName);
end;

function ikarus.delegates.PartyUnitDelegateClass:ConfigureProfile(index, visible)

	local config = self:Profile();
	local frame = "Ikarus_PartyFrameUnitFrame"..index;
	
	self.frame = getglobal(frame);
	self.index = index;
	self.unit = "party"..index;
	self.visible = config.GENERAL.VISIBLE;
	self.docking = config.DOCKING.ENABLE;
	
	config.GENERAL.FRAME = frame;
	config.GENERAL.DEFAULT_FRAME = "UnitFrame_party"..index;
	if(visible == nil) then
		config.GENERAL.VISIBLE = (UnitExists(self.unit) and not (config.GENERAL.HIDE_IN_RAID and GetNumRaidMembers() > 0)) 
			or (self.visible and self:IsDummy());
	else
		config.GENERAL.VISIBLE = visible;
	end;
	
	config.DOCKING.ENABLE = false;
	
	config.HEALTHBAR.FRAME = frame.."HealthBar";
	config.HEALTHBAR.LEFTTEXT_FRAME = frame.."HealthBarLeftText";
	config.HEALTHBAR.RIGHTTEXT_FRAME = frame.."HealthBarRightText";
	config.HEALTHBAR.OUTSIDE_LEFTTEXT_FRAME = frame.."HealthBarOutsideLeftText";
	config.HEALTHBAR.OUTSIDE_RIGHTTEXT_FRAME = frame.."HealthBarOutsideRightText";
	
	config.MANABAR.FRAME = frame.."ManaBar";
	config.MANABAR.LEFTTEXT_FRAME = frame.."ManaBarLeftText";
	config.MANABAR.RIGHTTEXT_FRAME = frame.."ManaBarRightText";
	config.MANABAR.OUTSIDE_LEFTTEXT_FRAME = frame.."ManaBarOutsideLeftText";
	config.MANABAR.OUTSIDE_RIGHTTEXT_FRAME = frame.."ManaBarOutsideRightText";
	
	config.SKILLBAR.FRAME = frame.."SkillBar";
	config.SKILLBAR.LEFTTEXT_FRAME = frame.."SkillBarLeftText";
	config.SKILLBAR.RIGHTTEXT_FRAME = frame.."SkillBarRightText";
	config.SKILLBAR.OUTSIDE_LEFTTEXT_FRAME = frame.."SkillBarOutsideLeftText";
	config.SKILLBAR.OUTSIDE_RIGHTTEXT_FRAME = frame.."SkillBarOutsideRightText";
	
	config.BUFFS.BUFFS_FRAME = frame.."BuffFrame";
	config.BUFFS.DEBUFFS_FRAME = frame.."DebuffFrame";
	config.PORTRAIT.FRAME = frame.."PortraitFrame";
	config.ICONS.DISCONNECT_FRAME = frame.."DisconnectIcon";
	config.ICONS.RAIDTARGET_FRAME = frame.."IconsFrameRaidTargetIcon";
	config.ICONS.PVPSTATE_FRAME = frame.."IconsFramePVPStateIcon";
	config.ICONS.LOOTMASTER_FRAME = frame.."IconsFrameLooterIcon";
	config.ICONS.RAIDLEADER_FRAME = frame.."IconsFrameLeaderIcon";
	config.ICONS.BOSS_FRAME = frame.."IconsFrameBossIcon";
	config.ICONS.MAINCLASS_FRAME = frame.."IconsFrameMainClassIcon";
	config.ICONS.SUBCLASS_FRAME = frame.."IconsFrameSubClassIcon";
	config.LABELS.TOPTEXT_FRAME = frame.."OutsideTopText";
	config.LABELS.LEFTTEXT_FRAME = frame.."OutsideLeftText";
	config.LABELS.BOTTOMTEXT_FRAME = frame.."OutsideBottomText";
	config.LABELS.RIGHTTEXT_FRAME = frame.."OutsideRightText";
end;

function ikarus.delegates.PartyUnitDelegateClass:UnregisterAllEvents()
	self:UnregisterEvents(self);
end;

function ikarus.delegates.PartyUnitDelegateClass:Unit()
	return "party";
end;

function ikarus.delegates.PartyUnitDelegateClass:SubUnit()
	return self.unit;
end;

function ikarus.delegates.PartyUnitDelegateClass:OnEvent(event, unit)
	local count = GetNumPartyMembers();
	if(count > 5) then
		count = 5;
	end;
	if(event == "PARTY_MEMBER_CHANGED") then
		--  WORKAROUND
		--  BUG: unit frame layout gets totally destroyed once a member change occurs.
		--	   unable to find the cause so far, just reloading bound properties (that is about 6 times the work)
		--self:LoadBoundProperties();
		--  DEFAULT
		--  delayed until bug is fixed
		self:UpdateAll();	
	elseif(event == "PARTY_LEADER_CHANGED") then
		for index = 1,count do
			self:ConfigureProfile(index);
			self:UpdatePartyLeaderIcon(self);
			self:ResetProfile();	
		end;	
	elseif(event == "RAID_TARGET_CHANGED") then
		for index = 1,count do
			self:ConfigureProfile(index);
			if(self.frame:IsVisible()) then
				self:UpdateRaidTargetIcon(self);
			end;
			self:ResetProfile();	
		end;	
	elseif(event == "LOOT_METHOD_CHANGED" or event == "UPDATE_LOOT_ASSIGN") then
		for index = 1,count do
			self:ConfigureProfile(index);
			self:UpdateLootMasterIcon(self);
			self:ResetProfile();	
		end;	
	elseif(event == "UNIT_TARGET_CHANGED") then
		for index = 1,count do
			self:ConfigureProfile(index);
			self:UpdateText(self);
			self:ResetProfile();	
		end;	
	elseif(ikarus.utils:IsValidString(unit) and string.sub(unit,1,5) == "party") then
		local index = tonumber(string.sub(unit,6,6));
		if(index > 0 and index < 6) then
			self:ConfigureProfile(index);
			if(self.frame:IsVisible()) then
				if(event == "UNIT_LEVEL" or event == "UNIT_CLASS_CHANGED")then
		            self:SuperClass():UpdateAll(self);
		        elseif(event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH")then
		            self:UpdateHealth(self);
					self:UpdateText(self);
		        elseif(event == "UNIT_MANA" or event == "UNIT_MAXMANA")then
		            self:UpdateMana(self);
					self:UpdateText(self);
		        elseif(event == "UNIT_SKILL" or event == "UNIT_MAXSKILL")then
		            self:UpdateSkill(self);
					self:UpdateText(self);
		        elseif(event == "UNIT_BUFF_CHANGED")then
		            self:UpdateBuffs(self);
					self:UpdateText(self);
		        elseif(event == "UNIT_PORTRAIT_UPDATE")then
		            self:UpdatePortrait(self);
		        end;
			end;
			self:ResetProfile();
		end;
	end;
end;

function ikarus.delegates.PartyUnitDelegateClass:OnScriptEvent(event, frame, key, ...)
	--ikarus.debug:Print(delegate.frame:GetName().." "..tostring(event).." "..tostring(key));
    if(event == "OnDragStart")then
        if not (self:Profile().GENERAL.FRAME_LOCKED or ikarus.ui:IsLocked()) then
            getglobal("Ikarus_PartyFrameUnitFrame1"):StartMoving("TOPLEFT");
        end;
    elseif(event == "OnDragStop")then
        if not (self:Profile().GENERAL.FRAME_LOCKED or ikarus.ui:IsLocked()) then
			local config = self:Profile();
			local frame = getglobal("Ikarus_PartyFrameUnitFrame1");
			frame:StopMovingOrSizing();
			local scale = GetUIScale() * tonumber(config.GENERAL.SCALE);
			local x, y = frame:GetPos();
            config.GENERAL.OFFSET_X, config.GENERAL.OFFSET_Y = x / scale, y / scale;
            ikarus.config:SaveProfile();
			self:UpdateAll();
        end;
    elseif(event == "OnClick" and key == "RBUTTON")then
		ToggleDropDownMenu(getglobal("UnitFrame_party"..frame:GetID().."DropDown"), 1, nil, frame:GetName());
    else
		self:SuperClass():OnScriptEvent(self, event, frame, key, ...);
    end;
end;

function ikarus.delegates.PartyUnitDelegateClass:HideDefaultFrame()
end;

function ikarus.delegates.PartyUnitDelegateClass:ShowDefaultFrame()
end;

function ikarus.delegates.PartyUnitDelegateClass:UpdateAll()
	if(ikarus.config:IsLoaded()) then
		local hide = (self:Profile().GENERAL.HIDE_IN_RAID and GetNumRaidMembers() > 0);
		if(hide or not self:Profile().GENERAL.VISIBLE) then
			getglobal(self:Profile().GENERAL.FRAME):Hide();
		else
			getglobal(self:Profile().GENERAL.FRAME):Show();
			for index = 1,5 do	
				self:ConfigureProfile(index);
				self:SuperClass():UpdateAll(self);
				self:UpdateDisconnectIcon();
				self:ResetProfile();
			end;	
		end;
		if(ikarus:GetDelegate("partytarget")) then
			ikarus:GetDelegate("partytarget"):SetEnabled(self:Profile().GENERAL.VISIBLE and not hide, true);
		end;	
    end;
end;

function ikarus.delegates.PartyUnitDelegateClass:UpdateDisconnectIcon()
	local name, online = GetPartyMember(self.index);
	if((name and not online) or self:IsDummy()) then
		if(self:Profile().ICONS.DISCONNECT_VISIBLE) then
			getglobal(self:Profile().ICONS.DISCONNECT_FRAME):Show();
		end;
		if not(self:IsDummy()) then
			self.frame:SetAlpha(0.5);
		end;
	else
		getglobal(self:Profile().ICONS.DISCONNECT_FRAME):Hide();
		self.frame:SetAlpha(1.0);
	end;
end;

--  Loads stuff like textures and other layout information from the profile
function ikarus.delegates.PartyUnitDelegateClass:LoadConfig()
	if(ikarus.config:IsLoaded()) then
		local hide = false;
		if(self:Profile().GENERAL.VISIBLE) then
			self:RegisterEvents(self);
			
			local frame;			
			hide = self:Profile().GENERAL.HIDE_IN_RAID and GetNumRaidMembers() > 0;
			for index = 1,5 do
				frame = getglobal("UnitFrame_party"..index);
				frame:UnregisterEvent("PARTY_MEMBER_CHANGED");
				frame:UnregisterEvent("PARTY_LEADER_CHANGED");
				frame:UnregisterEvent("UNIT_CLASS_CHANGED");
				frame:UnregisterEvent("UNIT_BUFF_CHANGED");
				frame:UnregisterEvent("RAID_TARGET_CHANGED");
				frame:UnregisterEvent("LOOT_METHOD_CHANGED");
				frame:UnregisterEvent("UNIT_NAME_UPDATE");
				frame:UnregisterEvent("UNIT_LEVEL");
				frame:UnregisterEvent("UNIT_PORTRAIT_UPDATE");
				frame:UnregisterEvent("RAID_TARGET_CHANGED");
				frame:UnregisterEvent("UNIT_RELATION");
				frame.healthBar:UnregisterEvent("UNIT_HEALTH");
				frame.healthBar:UnregisterEvent("UNIT_MAXHEALTH");
				frame.manaBar:UnregisterEvent("UNIT_MANA");
				frame.manaBar:UnregisterEvent("UNIT_MAXMANA");
				frame.skillBar:UnregisterEvent("UNIT_SKILL");
				frame.skillBar:UnregisterEvent("UNIT_MAXSKILL");
				frame:Hide();
				
				self:ConfigureProfile(index, true);
				self:SuperClass():LoadConfig(self);	
				self:SuperClass():LoadBoundProperties(self);
				self:LoadSubFrameProperties(self:Profile().ICONS, self:Profile().GENERAL.FRAME, "DISCONNECT", GetUIScale() * tonumber(self:Profile().GENERAL.SCALE));	
				self:SuperClass():UpdateAll(self);	
				self:UpdateDisconnectIcon();
				if(hide) then
					getglobal(self:Profile().GENERAL.FRAME):Hide();
				end;
				self:ResetProfile();
			end;
			self:RealignFrames();
		else
			self:UnregisterEvents(self);
			getglobal(self:Profile().GENERAL.FRAME):Hide();
			
			if(self:Profile().GENERAL.USE_DEFAULT_FRAME) then
				local frame;
				for index = 1,5 do
					frame = getglobal("UnitFrame_party"..index);
					frame:RegisterEvent("PARTY_MEMBER_CHANGED");
					frame:RegisterEvent("PARTY_LEADER_CHANGED");
					frame:RegisterEvent("UNIT_CLASS_CHANGED");
					frame:RegisterEvent("UNIT_BUFF_CHANGED");
					frame:RegisterEvent("RAID_TARGET_CHANGED");
					frame:RegisterEvent("LOOT_METHOD_CHANGED");
					frame:RegisterEvent("UNIT_NAME_UPDATE");
					frame:RegisterEvent("UNIT_LEVEL");
					frame:RegisterEvent("UNIT_PORTRAIT_UPDATE");
					frame:RegisterEvent("RAID_TARGET_CHANGED");
					frame:RegisterEvent("UNIT_RELATION");
					frame.healthBar:RegisterEvent("UNIT_HEALTH");
					frame.healthBar:RegisterEvent("UNIT_MAXHEALTH");
					frame.manaBar:RegisterEvent("UNIT_MANA");
					frame.manaBar:RegisterEvent("UNIT_MAXMANA");
					frame.skillBar:RegisterEvent("UNIT_SKILL");
					frame.skillBar:RegisterEvent("UNIT_MAXSKILL");
					frame:Show();
				end;
			end;
		end;
		
		if(ikarus:GetDelegate("partytarget")) then
			ikarus:GetDelegate("partytarget"):SetEnabled(self:Profile().GENERAL.VISIBLE and not hide, true);
		end;	
    end;
end;

function ikarus.delegates.PartyUnitDelegateClass:LoadBoundProperties()
	if(ikarus.config:IsLoaded()) then
		local hide = self:Profile().GENERAL.HIDE_IN_RAID and GetNumRaidMembers() > 0;
		for index = 1,5 do
			self:ConfigureProfile(index, true);
			self:SuperClass():LoadBoundProperties(self);	
			self:LoadSubFrameProperties(self:Profile().ICONS, self:Profile().GENERAL.FRAME, "DISCONNECT", GetUIScale() * tonumber(self:Profile().GENERAL.SCALE));
			self:SuperClass():UpdateAll(self);
			self:UpdateDisconnectIcon();
			self:ResetProfile();	
		end;
		self:RealignFrames();
		
		if(ikarus:GetDelegate("partytarget")) then
			ikarus:GetDelegate("partytarget"):SetEnabled(self:Profile().GENERAL.VISIBLE and not hide, true);
		end;	
    end;
end;


function ikarus.delegates.PartyUnitDelegateClass:RealignFrames()				
	--  Align unit frames
	local config = self:Profile();
	local xSpace, ySpace, alignment = 0,0,nil;
	if(config.GENERAL.ORIENTATION == "HORIZONTAL") then
		xSpace = config.GENERAL.SPACING;
		alignment = "RIGHT";
	else
		ySpace = config.GENERAL.SPACING;
		alignment = "BOTTOM";
	end;
	
	local frame = getglobal("Ikarus_PartyFrameUnitFrame1");
	
	if(config.DOCKING.ENABLE) then
		local target = ikarus.profile[string.lower(config.DOCKING.TARGET)].GENERAL.FRAME;
		config.GENERAL.FRAME_LOCKED = true;
		ikarus.ui:SetAlignment(frame, target, config.DOCKING.ALIGNMENT, config.DOCKING.OFFSET_X, config.DOCKING.OFFSET_Y, GetUIScale());
	else
		ikarus.ui:SetAnchor(frame, "UIParent", "TOPLEFT", "TOPLEFT", config.GENERAL.OFFSET_X, config.GENERAL.OFFSET_Y, GetUIScale());
	end;
	
	local parent = frame;
	for index = 2,5 do
		frame = getglobal("Ikarus_PartyFrameUnitFrame"..index);
		ikarus.ui:SetAlignment(frame, parent, alignment, xSpace, ySpace, GetUIScale());
		parent = frame;
	end;

	ikarus.ui:Resize(getglobal("Ikarus_PartyFrame"), config.GENERAL.WIDTH, config.GENERAL.HEIGHT);
	getglobal("Ikarus_PartyFrame"):Show();
end;
--  ***********************************************************************

--  Instantiate our delegate 
return ikarus.delegates.PartyUnitDelegateClass:Create();
	
end;